﻿using FuzzyTaskList;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace TestProject1
{
    
    [TestClass()]
    public class TaskItemTest
    {
        private static FuzzyTaskItem _target;
        public TestContext TestContext { get; set; }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class

        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestInitialize()]
        public void MyTestInitialize()
        {
            _target = new FuzzyTaskItem("xx", 2, 3);
        }

        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
        }

        [TestMethod()]
        public void HistviewCount()
        {
            Assert.AreEqual(1 +  FuzzyTaskList.Properties.Settings.Default.FutureDays , _target.HistoryView.Count);
        }
        [TestMethod]
        public void HistViewAllInactive()
        {
            foreach (var ai in _target.HistoryView)
            {
                Assert.IsFalse(ai.IsActivityComplete);
            }
        }

        [TestMethod]
        public void HistViewInialStatus()
        {
            for (int ii = 0; ii < _target.HistoryView.Count; ii++)
            {
                Assert.AreEqual(ActivityStatus.Late, _target.HistoryView[ii].ActivityStatus);    
            }
        }
        [TestMethod]
        public void TestFirstItemComplete()
        {
            _target.HistoryView[0].IsActivityComplete = true;
            _target.HistoryView[4].IsActivityComplete = true;

            Assert.AreEqual(ActivityStatus.IsComplete, _target.HistoryView[0].ActivityStatus);
            Assert.AreEqual(ActivityStatus.TooSoon, _target.HistoryView[1].ActivityStatus);
            Assert.AreEqual(ActivityStatus.CanAct, _target.HistoryView[2].ActivityStatus);
            Assert.AreEqual(ActivityStatus.ShouldAct, _target.HistoryView[3].ActivityStatus);
            Assert.AreEqual(ActivityStatus.IsComplete, _target.HistoryView[4].ActivityStatus);
            Assert.AreEqual(ActivityStatus.TooSoon, _target.HistoryView[5].ActivityStatus);
            Assert.AreEqual(ActivityStatus.CanAct, _target.HistoryView[6].ActivityStatus);
            Assert.AreEqual(ActivityStatus.ShouldAct, _target.HistoryView[7].ActivityStatus);
            for (int ii = 8; ii < _target.HistoryView.Count; ii++)
            {
                Assert.AreEqual(ActivityStatus.Late, _target.HistoryView[ii].ActivityStatus);
            }
        }

        [TestMethod]
        public void SetFirstandMaxItemComplete()
        {
            ActivityItem taa = _target.HistoryView[0];
            taa.IsActivityComplete = true;
            Assert.IsTrue(taa.IsActivityComplete);

            Assert.AreEqual(ActivityStatus.IsComplete, _target.HistoryView[0].ActivityStatus);
            Assert.AreEqual(ActivityStatus.TooSoon, _target.HistoryView[1].ActivityStatus);
            Assert.AreEqual(ActivityStatus.CanAct, _target.HistoryView[2].ActivityStatus);
            Assert.AreEqual(ActivityStatus.ShouldAct, _target.HistoryView[3].ActivityStatus);
            for (int ii = 4; ii < _target.HistoryView.Count; ii++)
            {
                Assert.AreEqual(ActivityStatus.Late, _target.HistoryView[ii].ActivityStatus);
            }
        }

    }
}
